C # math. Round () Achieves Chinese rounding
Math. Round () in C # does not use the "Rounding" method. In fact, in VB, VBScript, C #, J #, T-SQL in the round function are using banker's rounding (Banker algorithm), namely:Four Homes, six in five
Round () Rounding out the js Banker algorithm, round banker
First, let's guess the result returned by round (0.825, 2,
First, SQL server Returns 0.83
The returned result of js is 0.83. The code is as follows:
Var B = 0.825; alert (Math. round (B * 1
Original: "C #" Excel Rounding function round, RoundUp, RoundDown C # versionIn C # I often miss the round in Excel, RoundUp, RoundDown These functions, the reason is the latter "Earth gas", compared to the rounding requirements of my small people,
In C # I often miss the round in Excel, RoundUp, RoundDown These functions, the reason is the latter "Earth gas", compared to the rounding requirements of my small people, what "banker rounding Method" Let the bankers to use it. Let's review some of
Let's take a look at an example:
1: DECLARE @Value float
2: SET @Value = 12.1785
3: SELECT '12.1785' as ValueToRound, ROUND(@Value,3) as RoundedValue
4: SET @Value = 12.1745
5: SELECT '12.1745' as ValueToRound,ROUND(@Value,3) as
It's been weird. Why is a decimal added to the predefined data types of C #, and is it enough to have float and double? Come and dig a hole today.
Floating-point type
Name
CTS Type
De script ion
Significant figures
Range
Transferred from: http://www.cnblogs.com/lovewife/articles/2466543.htmlSingle precision refers to a 4-byte floating-point number, which is the floatA double is a 8-byte floating-point number, which is doubleDecimal is a high precisionFloating point
2.1 2.6-2.1-2.6Floor: Maximum integer not greater than the argument 2 2-3-3Ceil: Maximum integer not less than argument 3 3-2-2Round: Rounding to nearest integer 2 3-2-3round (num,num_dight) accurate num to num_dight number of digitsFloor (), ceil ()
C language 11th round: pre-processing command of the concentration camp"Learning goals"1. Macro definition2. The document includes "processing3. Conditional compilationPreprocessing commands: An environment that improves program design. Improve
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.